package com.wj.LightActivity;

import android.app.Application;
import android.content.pm.FeatureInfo;
import android.content.pm.PackageManager;
import android.hardware.Camera;
import android.os.Process;

public class MyApplication extends Application {
	private static MyApplication myAppliaction = null;
	private Camera camera = null;

	public static MyApplication getMyApplication() {
		return myAppliaction;
	}

	public void exit() {
		this.camera.setPreviewCallback(null);
		this.camera.release();
		this.camera = null;
		try {
			Process.killProcess(Process.myPid());
			System.exit(0);
			return;
		} catch (Exception localException) {
		}
	}

	public Camera getCamera() {
		return this.camera;
	}

	public void onCreate() {
		super.onCreate();
		PackageManager pm = this.getPackageManager();
		FeatureInfo[] fi = pm.getSystemAvailableFeatures();
		for(FeatureInfo feature:fi) {
			if(PackageManager.FEATURE_CAMERA_FLASH.equals(feature.name)) {
				this.camera = Camera.open();
				Config.hasFlash = true;
			}
		}
		myAppliaction = this;
	}
}